Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate nullable as type alias and resolve recursive reference in union #2989

Merged
merged 14 commits into from
Jan 27, 2025

Conversation

v-jiaodi
Copy link
Member

@v-jiaodi v-jiaodi commented Jan 10, 2025

fixes #2993

@MaryGao MaryGao self-assigned this Jan 10, 2025
@qiaozha qiaozha assigned qiaozha and unassigned MaryGao Jan 15, 2025
@MaryGao MaryGao changed the title Test arm keyvault Test dpg keyvault Jan 24, 2025
} | null;

// @public
export type ErrorModel_1 = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maorleger this PR can fix the generation error, but it will have duplicate models issue because of this Azure/typespec-azure#1677 (comment) And @tadelesh will fix that after the holiday in tcgc. will you be okay with this fix for now and remove the duplicated models while you prepare the PR ? And we will fix this in emitter side after the holiday.
If you agree with this, I will try to release a new emitter with the current fix before the holiday.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@qiaozha thanks for the heads up - this will be fine for me as KeyVault's generated code is not directly exported. We have a convenience layer and can smooth over any duplication as this. Thank you!

@qiaozha qiaozha changed the title Test dpg keyvault Generate nullable as type alias and resolve recursive reference in union Jan 24, 2025

// @public
export type Stop = string | string[];
export type Prompt_1 = string | string[] | number[] | number[][];
Copy link
Member

@MaryGao MaryGao Jan 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i was thinking if we should delivery an alpha verion for keyvalut first. the correct fix without xxx_1 should be non-breaking, but this pr would introduce a breaking.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

breaking only exists when there's a real release, and as far as I know keyvault is the only one that has this issue and is going to release, and @maorleger already said they will not release with this duplicate _N suffix. And it seems like an easy fix and can be easily caught during the review stage.
However, any services that are using recursive self reference union would have the same generation crash issue in pipeline. Compare with the generation crash there, we then spend resources to investigate during this period, I prefer to have a new release out with the latest tag.
/cc @joheredi @xirzec Could you kindly keep that in mind while you review the servics onboarding PR? Thanks.

@qiaozha qiaozha marked this pull request as ready for review January 26, 2025 09:56
@qiaozha qiaozha requested a review from joheredi as a code owner January 26, 2025 09:56

// @public
export type Stop = string | string[];
export type Prompt_1 = string | string[] | number[] | number[][];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this because tcgc wrongly tagged this union type as name type but it should be an anoymous one?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, see issue here Azure/typespec-azure#2133

// We already know it's not a model type
const variantType = getSchemaForType(dpgContext, variant.type, {
...options,
needRef: isAnonymousModelType(variant.type) ? false : true
Copy link
Member

@MaryGao MaryGao Jan 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it because we change the needRef condition so we fix the max stack issue in RLC? I was just thinking if this is a generic way to fix this and if there is other cases we didn't consider. Can we verify it?

union A {
          null,
          A
        }

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tcgc has a problem handle the case too Azure/typespec-azure#2132

Copy link
Member

@MaryGao MaryGao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to block this but did left some comments, please take a look!

@qiaozha qiaozha merged commit fd70b10 into Azure:main Jan 27, 2025
17 checks passed
@qiaozha qiaozha deleted the test110 branch January 27, 2025 02:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

keyvaults admin generation failure
4 participants